package com.example.customviewtest.clipImage;

import android.content.Context;
import android.util.Log;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.customviewtest.R;

import java.util.List;

/**
 * @auther XuDan on 2020/4/22.
 */
class ImgAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private Context mContext;
    private final int mWidth;

    public ImgAdapter(Context context, int layout, List<String> img_list) {
        super(layout, img_list);
        this.mContext = context;
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mWidth = windowManager.getDefaultDisplay().getWidth() / 4;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView item_img = helper.getView(R.id.item_img);
        ViewGroup.LayoutParams layoutParams = item_img.getLayoutParams();
        layoutParams.width = mWidth;
        layoutParams.height = mWidth;
        item_img.setLayoutParams(layoutParams);
        Glide.with(mContext).load(item).into(item_img);
    }
}
